package android.example;

import java.util.ArrayList;

import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.media.MediaPlayer;
import android.util.Log;
import android.widget.Toast;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class ImageItemizedOverlay extends ItemizedOverlay {
	private Context mContext;
	private ArrayList <OverlayItem> mOverlays = new ArrayList<OverlayItem>();
	private MediaPlayer mp;
	//private Intent intent;
	public ImageItemizedOverlay(Drawable defaultMarker, Context context) {
		super(boundCenterBottom(defaultMarker));
		// TODO Auto-generated constructor stub
		mContext = context;
	}
	@Override
	protected OverlayItem createItem(int i) {
		// TODO Auto-generated method stub
		return mOverlays.get(i);
	}

	@Override
	public int size() {
		// TODO Auto-generated method stub
		return mOverlays.size();
	}
	public void addOverlay(OverlayItem o) {
		mOverlays.add(o);
		populate();
	}
	
	@Override
	protected boolean onTap(int index) {
		//메뉴, 웹, 음악이 흘러 나오도록 변경한 번 해봐봐봐~~~~
		
		
		/*
		MediaPlayer mp2 = new MediaPlayer();
		try {       			
			mp2.setDataSource("/mnt/sdcard/data/Beyonce-Sweet Dreams.mp3");
			mp2.prepare();        		
		} catch (Exception e) {
			Log.d("Haha Error",e.getMessage());
		} 
		mp2.start();        		
		mp2.setOnCompletionListener(new OnCompletionListener() {
			public void onCompletion(MediaPlayer arg0) { 
				Toast.makeText(getApplicationContext(),"Play2 end",Toast.LENGTH_LONG).show();
			}        			
		});
		
		return true;*/
		
		OverlayItem item = mOverlays.get(index);
		AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
		dialog.setTitle(item.getTitle());
		dialog.setMessage(item.getSnippet());
		dialog.show();
		return true;
		
	}

}
